Skip to content

Instantly share code, notes, and snippets.

View avoidwork's full-sized avatar

Jason Mulligan avoidwork

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@bellbind
bellbind / es5compat-gs.js
Created May 31, 2011 15:45
[js]Missing ECMAScript5 standard function for Opera11 and Safari5
(function (global) {
// Missing ECMAScript5 standard functions for Opera and Safari
// support getter/setter with non standard funcs
// add the script tag to html at first:
// <script src="https://gist.github.com/raw/1000718/es5compat-gs.js"
// ></script>
// dummy Object protection interface for Opera11 and Safari5
Object.isFrozen = (
Object.isFrozen || function isFrozen(obj) {return false;});
@csanz
csanz / encrypt_decrypt.js
Created August 30, 2011 16:06
Simple String Encryption & Decryption with Node.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@avoidwork
avoidwork / filesize.js
Created March 24, 2012 01:05
filesize.js
filesize(500); // "3.91Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46KB"
filesize("1500000000"); // "1.40GB"
filesize("1500000000", 0); // "1GB"
filesize(1212312421412412); // "1.08PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to *nix "ls -lh"
# setup fd 3 as udp connection to drone
exec 3<>/dev/udp/192.168.1.1/5556
# takeoff
echo -e "AT*REF=1,512\r" >&3
# landing
echo -e "AT*REF=2,0\r" >&3
...
# profit?
@jalaziz
jalaziz / README.md
Created August 14, 2014 02:25
Sentry upstart and nginx configs

Setup

  1. Create a new user on the system:

    sudo adduser --system --group --shell /bin/bash --home /opt/sentry sentry
  2. Create the virualenv and install the required packages:

@fta2012
fta2012 / ReplicatedRandomChrome.js
Last active January 15, 2020 05:44
EDIT: This code no longer works on chrome but still works for legacy versions of node. Updated code moved to https://github.com/fta2012/ReplicatedRandom/tree/master/node.
var rngstate;
function MathRandom() {
// Our own implementation of Math.random().
// Source code was copied from https://github.com/v8/v8/blob/4.6.85/src/math.js#L131
// You need to initialize rngstate with `solve` before this can be used.
// If using node.js, you have to s/18030/18273/g here and in `solve` since they implement it slightly differently: https://github.com/nodejs/node-v0.x-archive/blob/d13d7f74d794340ac5e126cfb4ce507fe0f803d5/deps/v8/src/math.js#L146
console.assert(rngstate, "You need to set the global variable `rngstate` first. For example: `rngstate = solve(Math.random(), Math.random());`");
if (!rngstate) return;
var r0 = (Math.imul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
rngstate[0] = r0;
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 29, 2024 17:57
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cam8001
cam8001 / vort3x.md
Last active September 1, 2023 18:31
Vortex / IKBC Pok3r keyboard guide for Mac OS